package BLC

import (
	"bytes"
	"encoding/binary"
	"encoding/json"
	"log"
	"strings"
)

//int64 转换成字节数组
func IntToHex(data int64) []byte {

	buffer := new(bytes.Buffer)
	err := binary.Write(buffer, binary.BigEndian, data)
	if err != nil {
		log.Panicf("int to []byte failed %v\n", err)
	}
	return buffer.Bytes()
}

//win 下的json 转换格式
//go run main.go send -from "[\" a\",\"b\"]" -to "[\"c\",\"d\"]"  -amount "[\"5\",\"3\"]"
func JsonToArray(str string) []string {
	var strArray []string
	err := json.Unmarshal([]byte(str), &strArray)
	if err != nil {
		log.Panicf("json to string failed! ", err)
	}
	return strArray
}

func StrToArray(str string) []string {
	var strArray []string
	strArray = strings.Split(str, ",")
	return strArray
}
